﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace EEDS.Core.IO
{
    public sealed class EmblemRenderer : IEmblemRenderer
    {
        public Bitmap RenderEmblem(Emblem emblem)
        {
            return emblem.Image;
        }

        public Bitmap OpenEmblem(Bitmap emblem)
        {
            if (!IsRenderer(emblem))
                throw new NotSupportedException("The image was not rendered with this renderer.");

            return emblem;
        }

        public bool IsRenderer(Bitmap emblem)
        {
            if (emblem.Width != 32 || emblem.Height != 32)
                return false;

            return GetPalettes(emblem).Length != 0;
        }

        Palette[] GetPalettes(Bitmap emblem)
        {
            Palette.FindMatchingPalettes(emblem, GamePalettes.Palettes);
        }

        private EmblemRenderer() { }
        public static readonly EmblemRenderer Instance = new EmblemRenderer();
    }
}
